package com.shg.web.ztest;

import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.shg.bean.Book;
import com.shg.bean.QueryResult;
import com.shg.bean.Users;
import com.shg.bean.bbs.Forum;
import com.shg.service.bbs.ForumService;

public class ForumServiceTest {

	private static ForumService forumService;
	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		ApplicationContext context=new ClassPathXmlApplicationContext("basics-application.xml");
		forumService =(ForumService)context.getBean("forumServiceBean");
	}

	@Test
	public void testInsert() {
		Forum entity=new Forum();
		Book book=new Book();
		entity.setBook(book);
		entity.setBrowse(1);
		entity.setContent("我觉得这本的最后一章写得很好");
		entity.setState(1);
		Users users=new Users();
		users.setId("ff80808135a033220135a033246c0000");
		entity.setUsers(users);
		forumService.insert(entity);
	}
	
	@Test 
	public void testGetDiscuss(){
		QueryResult<Forum> result=null;
		try {
			result = forumService.getDiscuss(0, 3, "402889673629f13401362a0371710000",0);
		} catch (Exception e) {
			e.printStackTrace();
		}
		for(Forum forum:result.getResultList()){
			System.out.println(forum.getContent());
		}
	}

}
